package com.yuandian.business.monitor.controller;

import com.yuandian.api.business_monitor.po.AlarmParams;
import com.yuandian.bpm.common.core.util.R;
import com.yuandian.business.monitor.service.IAlarmTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 告警类型Controller
 *
 * @Author wangpeiyang
 * @Date 2021/5/26 9:40
 */
@Api(value = "alarmType", tags = "告警类型接口")
@RestController
@RequestMapping("/alarm/type")
public class AlarmTypeController {

    @Autowired
    private IAlarmTypeService alarmTypeService;

    /**
     * 查询告警类型占比数据
     *
     * @param params 参数
     * @return 通用返回对象
     */
	@ApiImplicitParams({
			@ApiImplicitParam(name = "systemId",  			value = "系统id",  			paramType = "query", 	required = true, 	dataType = "Integer"),
			@ApiImplicitParam(name = "pageSize", 		value = "分页大小", 			paramType = "query", 	required = true,  	dataType = "Integer"),
			@ApiImplicitParam(name = "pageNum", 	value = "当前页面", 		paramType = "query", 	required = true,  	dataType = "Integer"),
			@ApiImplicitParam(name = "currentTime", 			value = "当前时间", 			paramType = "query", 	required = true,    dataType = "String")
	})
    @PostMapping("/queryAlarmProportion")
	@ApiOperation(value = "查询告警类型占比数据", notes = "查询告警类型占比数据")
    public R queryAlarmProportion(AlarmParams params) {
        if (params == null) {
            return R.failed("参数不能为空");
        }
        if (params.getSystemId() == null) {
            return R.failed("系统Id不能为空");
        }
        return R.ok(alarmTypeService.getAlarmProportion(params));
    }
}
